class Solution:
    def __init__(self):
        self.result = ""
        self.length = len(self.result)

    def check_is_palindroimc_str(self, input_string):
        new_string = input_string[::-1]
        if input_string == new_string:
            return True
        else:
            return False

    def longestPalindrome(self, s: str) -> str:
        if len(s) >= 1:
            self.result = s[0]
        for i in range(len(s)):
            index = s.find(s[i], i+1)
            while(index != -1):
                tmpString = s[i:index+1]
                if self.check_is_palindroimc_str(tmpString) == True:
                    if len(tmpString) > self.length:
                        self.result = tmpString
                        self.length = len(tmpString)
                index = s.find(s[i], index + 1)
        return self.result



if __name__ == '__main__':
    sl = Solution()
    # print(sl.longestPalindrome("babadab"))
    # print(sl.longestPalindrome("a"))
    # print(sl.longestPalindrome("ab"))
    print("xxxx", sl.longestPalindrome(""))

